/*
 * @file    type_info.cpp
 * @author  Luo ZhiHui <camel.flying@gmail.com>
 * @version 1.0
 *
 * @section LICENSE
 *
 *
 * @section DESCRIPTION
 * test type_info class
 *
 */

#include <iostream>
#include <typeinfo>

using namespace std;

struct Base
{};

struct Derived:Base
{};

struct Poly_Base
{
    virtual void Member(){}
};

struct Poly_derived:Poly_Base
{
};

int main(int argc, char **argv)
{
    /*build-in types*/
    int index=0;
    int *pointer_index;

    cout << "int is: " << typeid(int).name() << endl;
    cout << "int is: " << typeid(index).name() << endl;
    cout << "int is: " << typeid(int *).name() << endl;
    cout << "int is: " << typeid(pointer_index).name() << endl;

    //non-polymorphic type
    Derived derived;
    Base *pointer_derived = &derived;
    cout << "derived is: " << typeid(derived).name() << endl;
    cout << "*pointer_derived is: " << typeid(*pointer_derived).name() << endl;
    cout << boolalpha << "same type" << endl;
    cout <<  (typeid(*pointer_derived) == typeid(derived)) << endl;

    //polymorphic type
    Poly_derived poly_derived;
    Poly_derived poly_derived1;
    Poly_derived poly_derived2;
    Poly_Base *poly_pointer_derived = &poly_derived;

    cout << "poly_derived is: " << typeid(poly_derived).name() << endl;
    cout << "poly_derived is: " << typeid(poly_derived1).name() << endl;
    cout << "poly_derived1 is: " << typeid(poly_derived2).name() << endl;

    cout << "poly_pointer_derived is: " << typeid(*poly_pointer_derived).name() << endl;
    cout << boolalpha << "same type" << endl;
    cout <<  (typeid(*poly_pointer_derived) == typeid(poly_derived)) << endl;

    return 0;
}
